package com.myacg.platform.living;

import java.awt.Graphics;
import java.util.Date;
import javax.swing.JComponent;

import com.myacg.core.entity.Point;
import com.myacg.core.task.KeepTask;
import com.myacg.core.task.KeepTaskManager;
import com.myacg.platform.view.stage.Stage;

public abstract   class BaseLiving extends StaticLiving{
	protected KeepTask task;
	
	protected BaseLiving(Point point) {
		super(point);
	}
 
 
	 
	 
 
	public abstract void run(); 
	/**
	 * 默认的执行方式
	 */
	public void RunStart(){
		System.out.println("baseLiving 的 runstart");
		this.RunStart(50);
	};
	/**
	 * 提供一种显式的启动任务 
	 * @param layter
	 * @param sleep
	 */
	public void RunStart(int sleep){
		task= new KeepTask(sleep) {
			@Override
			public void secondExecute() {
				 run();
			}
			@Override
			public void overExecute() {
				 whenOver();
			}
		};
		//创建任务
	    KeepTaskManager.getInstance().addTask(task);
	};
 
	/**
	 * 注销自己的任务
	 */
	@Override
	public void distoraySelf() {
		super.distoraySelf();
			//解除任务
			if(task!=null){
				task.over();
			}
	}
 
}
